﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.IO;
using System.Data;

public partial class member_CheckFile : System.Web.UI.Page
{
	public string EnterpriseName = "";
    public string UserID = "";
    public string UserPower = "";
    public string Footer = "";
	
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Init.islogin(ref UserID,ref EnterpriseName,ref UserPower))
        {
            Response.Redirect("/Login.aspx");
        }
        if (!UserPower.Contains("Manager"))
        {
            Response.Write("你没有权限！");
            Response.End();
        }
        CheckFile();
    }
    Common Init = new Common();
    MsSqlHelper mssql = new MsSqlHelper();

    public void CheckFile() {

        DataTable dt = new DataTable();
        string sql = "";
        sql = "select distinct rtrim(url) url,rtrim(imageid) plh,rtrim(c.spmch) as spmch,rtrim(b.extend) as extend,rtrim(type_id) type_id,rtrim(b.leibie) as leibie,rtrim(b.fzxx1) as pihao"
           + " from [ImageDoc] b(nolock),spkfk c(nolock) where c.spid=b.detailid";

        dt = mssql.ExecuteDt(sql);

        for (int n = 0; n < dt.Rows.Count; n++)
        {
            //string filename = "H:\\" + dt.Rows[n]["url"].ToString().Replace("Upload", "TuPian");
            string filename = Init.imagefileurl(dt.Rows[n]["url"].ToString());

            if (!File.Exists(filename))
            {
                mssql.ExecuteSql("insert into tmp(imageid,url,path)values('" + dt.Rows[n]["plh"].ToString() + "','" + dt.Rows[n]["url"].ToString() + "','" + filename + "')");
            }
        }
        Response.Write("完成");
            
    }
}